Skip to content

feat: Add custom_properties to github_repository and github_enterpris…#3322

Open
faradayfan wants to merge 3 commits intointegrations:mainfrom
faradayfan:custom-properties
Open

feat: Add custom_properties to github_repository and github_enterpris…#3322
faradayfan wants to merge 3 commits intointegrations:mainfrom
faradayfan:custom-properties

Conversation

@faradayfan
Copy link
Copy Markdown

@faradayfan faradayfan commented Apr 6, 2026

feat: Add custom_properties to github_repository and github_enterprise_custom_property resource

Allow custom properties to be set on repositories at creation time, fixing 422 errors when an organization enforces required custom properties. Also adds a new github_enterprise_custom_property resource and data source for managing custom property definitions at the enterprise level.

Resolves #3230, #3304


Before the change?

  • Organizations enforcing required custom properties would cause github_repository to return a 422 error on creation, since custom properties could only be set via a separate github_repository_custom_property resource applied after creation
  • There was no Terraform resource or data source for defining custom property schemas at the enterprise level

After the change?

  • github_repository now accepts a custom_properties argument (a string map) that is included in the initial repository creation request, satisfying organization-required custom properties at creation time
  • A new github_enterprise_custom_property resource allows managing custom property definitions at the enterprise level, mirroring the existing github_organization_custom_properties resource
  • A new github_enterprise_custom_property data source allows reading enterprise custom property definitions
  • Documentation added for the new resource and data source, and updated for github_repository with a new argument description and example
  • Acceptance tests added using testResourcePrefix naming and ConfigStateChecks pattern

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

  • Yes
  • No

Behavior Note About custom_properties on github_repository

This change adds a custom_properties attribute to github_repository that allows setting repository-level custom property values defined by the organization.

Example

resource "github_repository" "example" {
  name = "my-repo"

  custom_properties = {
    tier     = "Tier 4"
    team  = "platform"
  }
}

Behavior

Create — Custom properties are included directly in the POST /orgs/{org}/repos request body. This satisfies organizations that enforce required custom properties at repository creation time (which would otherwise reject the request with a 422).

Update — Changes are applied via the dedicated PATCH /repos/{owner}/{repo}/properties/values endpoint. The general repository update endpoint (PATCH /repos/{owner}/{repo}) silently ignores custom property changes, so the dedicated endpoint is required.

Read — Property values are refreshed from GET /repos/{owner}/{repo}/properties/values on each plan so out-of-band changes are detected as drift.

Config semantics

Config Result
custom_properties = { key = "value" } Sets the property value
Remove a specific key from the map Clears that property value (sends null)
custom_properties = {} Clears all managed property values
Remove the entire custom_properties block No change — leaves existing values untouched

The last row is intentional and follows Terraform's Optional + Computed convention: org-required properties shouldn't be implicitly cleared, and accidental block removal shouldn't wipe values. Use custom_properties = {} to explicitly clear all values.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@faradayfan faradayfan force-pushed the custom-properties branch 2 times, most recently from 9efa7f0 to c96926f Compare April 7, 2026 19:13
@deiga deiga added this to the v6.13.0 Release milestone Apr 14, 2026
@faradayfan
Copy link
Copy Markdown
Author

Just to be transparent, I haven't tested these changes manually. They are based on API documentation. I'm planning on testing the repository resource changes, but I don't think I'll be able to test the enterprise custom properties. Is that something a maintainer can validate for me? Or is there a manual testing harness I can use to validate those changes myself?

@Wirone
Copy link
Copy Markdown

Wirone commented Apr 16, 2026

We're super-interested in this change, and have Enterprise waiting for this automation. If we can help with testing it, just let us know, I'll try to do it.

…e_custom_property resource (integrations#3230, integrations#3304)

Allow custom properties to be set on repositories at creation time,
fixing 422 errors when an organization enforces required custom
properties. Adds a new github_enterprise_custom_property resource and
data source for managing custom property definitions at the enterprise
level. Uses context-aware CRUD functions, proper 404 handling, and
ConfigStateChecks in acceptance tests per maintainer guidelines.

Closes integrations#3230, integrations#3304
- include custom_properties in create request body to satisfy org-required
  property enforcement at creation time
- read custom_properties via dedicated GetAllCustomPropertyValues endpoint
  instead of repo.CustomProperties (which GET /repos never populates)
- handle partial and full removal in update via CreateOrUpdateCustomProperties
  with null values; removing the block entirely leaves existing values intact
  (Optional+Computed behavior)
Covers all documented config semantics: setting at creation time, updating
values, removing individual map keys, clearing via empty map, and the
Optional+Computed no-op when the block is removed entirely.
@faradayfan
Copy link
Copy Markdown
Author

I've validated the custom_properties property on the github_repository resource through manual testing and provided a breakdown of the behavior on the PR summary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Add support for defining custom properties for an enterprise

3 participants